#ifndef _BUOLA_GUI_CONTAINERS_CLISTCONTAINER_H_
#define _BUOLA_GUI_CONTAINERS_CLISTCONTAINER_H_

#include <buola/gui/cwindow.h>

namespace buola { namespace gui {

class CListContainer : public CWindow
{
    struct SWindow
    {
        PWindow mWindow;
        CRect_d mMargins;
        CRect_d mRect;
    };

    struct SGroup
    {
        TID mID;
        std::wstring mName;

        double mY;
        bool mExpanded;

        std::vector<SWindow> mWindows;
    };


public:
    CListContainer();
    virtual ~CListContainer();

    TID AddGroup(const std::wstring &pName,TID pID=-1);
    void RemoveGroup(TID pID);

    void Add(const PWindow &pWindow,TID pGroup,const CRect_d &pMargins=CRect_d(nUndefined));
    
    virtual void OnLayout();
    virtual void OnExpose(const CExposeEvent &pE);
    virtual void OnButtonDown(const CMouseEvent &pE);
    virtual void OnMouseWheel(const CMouseEvent &pE);
    virtual void OnChildRemoved(const PWindow &pWindow);
    void OnVScroll(int pPos);

private:
    int mNextID;
    std::vector<std::unique_ptr<SGroup>> mGroups;
    std::unordered_map<TID,SGroup*> mGroupsByID;

    double mYScroll;

    PScrollBar mVScroll;
};

/*namespace gui*/ } /*namespace buola*/ }

#endif
